<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>代码生成器</title>
    <!-- import Vue.js -->
    <script src="http://lib.baomitu.com/vue/2.6.14/vue.min.js"></script>
    <!-- import stylesheet -->
    <link rel="stylesheet" href="http://lib.baomitu.com/view-design/4.6.1/styles/iview.css">
    <!-- import iView -->
    <script src="http://lib.baomitu.com/view-design/4.6.1/iview.js"></script>
    <script src="http://lib.baomitu.com/axios/0.21.4/axios.min.js"></script>
</head>
<body>
<div id="app" style="padding-top: 1px">
    <i-table border ref="selection" :columns="columns" :data="tables">
        <template slot-scope="{ row, index }" slot="action">
            <i-button type="primary" size="small" style="margin-right: 5px" @click="edit(row)">配置</i-button>
        </template>
    </i-table>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            columns: [
                {
                    type: 'index',
                    width: 60,
                    align: 'center'
                },
                {
                    title: '表名',
                    key: 'NAME'
                },
                {
                    title: '描述',
                    key: 'COMMENT'
                },
                {
                    title: '操作',
                    slot: 'action',
                    width: 150,
                    align: 'center'
                }
            ],
            tables: []
        },
        methods: {
            getTables: function () {
                axios.post('/generate/tables', {}).then( (response)=> {
                    this.tables=response.data.data;
                    console.log(response.data.data)
                }).catch( (error)=> {
                        //console.log(error);
                });
            },
            edit:function (row) {
                console.info(row)
                window.location.href="/generate/edit?tableName="+row.NAME;
            }
        },
        created: function () {
           this.getTables()
        }
    })
</script>
</body>
</html>
